# -*- coding: utf-8 -*-
# @Time: 2021/11/11 20:39
# @Author: lijinxi
# @File    : queue_minimum.py
# @desc

# -*- coding: utf-8 -*-
# @Time: 2021/11/11 20:33
# @Author: lijinxi
# @File    : switch_optimal.py
# @desc
from service_placement_request_schedule import *

delays = []


def queue_optimal():
    sprs = ServicePlacementRequestSchedule()
    sprs.initialize_requests()
    # 最开始的服务放置，初始化为0或随机值
    last_service_placement = np.zeros(
        shape=(sprs.number_requests, sprs.type_network_functions, sprs.number_access_points), dtype=np.int8)
    for t in range(1, 21):  # 20个时隙
        print("==" * 60)
        print(t)
        sprs.update_trace(time_slot=t - 1)
        last_service_placement, delay = sprs.queue_minimum(last_service_placement)
        delays.append(delay)


if __name__ == '__main__':
    queue_optimal()
    print(delays)
